//
//  MYGFriendsChatTableViewCell.swift
//  MYDoctor
//
//  Created by 小火科技 on 2024/4/15.
//

import UIKit

class MYGFriendsChatTableViewCell: UITableViewCell {

    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        selectionStyle = .none
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .white
        contentView.addSubview(avatar)
        contentView.addSubview(nameLabel)
        contentView.addSubview(typeLabel)
        contentView.addSubview(timeLabel)
        contentView.addSubview(contentLabel)
        contentView.addSubview(dian)
        contentView.addSubview(numLabel)
        reloadLayout()
    }
    
    private func reloadLayout() {
 
        avatar.snp.remakeConstraints { make in
            make.left.equalToSuperview().offset(25)
            make.top.equalToSuperview().offset(20)
            make.width.height.equalTo(50)
        }
        dian.snp.makeConstraints { make in
            make.width.height.equalTo(10)
            make.right.equalTo(avatar)
            make.top.equalTo(avatar.snp.top).offset(10)
        }
        nameLabel.snp.remakeConstraints { make in
            make.left.equalTo(avatar.snp.right).offset(10)
            make.top.equalTo(avatar)
        }
        
        typeLabel.snp.makeConstraints { make in
            make.left.equalTo(nameLabel.snp.right).offset(10)
            make.centerY.equalTo(nameLabel)
        }
        timeLabel.snp.makeConstraints { make in
            make.centerY.equalTo(nameLabel)
            make.right.equalToSuperview().offset(-25)
        }
        
        contentLabel.snp.makeConstraints { make in
            make.left.equalTo(nameLabel)
            make.bottom.equalTo(avatar)
        }
        
        numLabel.snp.makeConstraints { make in
            make.width.height.equalTo(13)
            make.bottom.equalTo(contentLabel)
            make.right.equalTo(timeLabel)
        }
        
    }
    
    // MARK: - lazy load
    private lazy var avatar: UIImageView = {
        let imgV = UIImageView()
        imgV.layer.masksToBounds = true
        imgV.layer.cornerRadius = 18
        imgV.image = UIImage(named: "head")
        return imgV
    }()
    
    private lazy var nameLabel: UILabel = {
        let label = UILabel()
        label.font = .medium(16)
        label.textColor = .rgba(44, 44, 44, 1)
        label.text = "刘医生"
        return label
    }()
    private lazy var typeLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .rgba(23, 114, 239, 1)
        label.text = "主治医师"
        
        label.layer.cornerRadius = 2
        label.layer.borderWidth = 0.5
        label.layer.borderColor = UIColor.rgba(90, 160, 255, 1).cgColor
        
        return label
    }()
    private lazy var timeLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .rgba(128, 128, 128, 1)
        label.text = "上午11:00"
        return label
    }()
    private lazy var contentLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .rgba(128, 128, 128, 1)
        label.text = " 请问有什么问题要咨询吗？"
        return label
    }()

    private lazy var dian: UIView = {
        let d = UIView()
        d.backgroundColor = .green
        d.layer.cornerRadius = 5
        d.layer.masksToBounds = true
        return d
    }()
    
    private lazy var numLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .white
        label.backgroundColor = .rgba(236, 54, 33, 1)
        label.text = "2"
        label.textAlignment = .center
        label.layer.cornerRadius = 6.5
        label.layer.masksToBounds = true
        return label
    }()
    

}
